type GeCiType = {
    text: string,
    time: number
}

let GeCi1: GeCiType[] = [
    {
        text: '一瞬间',
        time: 20.812
    },
    {
        text: '法则颠覆',
        time: 52421.234
    }
]

/**
 * @description 练习类型约束 使用type 前缀 可以约束引用数据类型的子类型
 * @param GeCiArr
 * @return GeCiType[]
 */
function renderGeCi(GeCiArr: GeCiType[]): GeCiType[] {
    let gcIndex: number = 0
    let gc: GeCiType[] = []
    while (gcIndex < GeCiArr.length + 1) {
        console.log('歌词解析...\n\n\n')
        gc.push(GeCiArr.pop())
        gc.push({text: 'oh!!!', time: new Date().getTime()})
        gcIndex++
    }
    return [...gc.reverse()]
}

const name = 'james'


type delayExecFnType = (fn: delayExecFnType, delay: number, ...args: (string | number | object)[]) => any
type callbackType = (...args: any[]) => void
const delayExecFn = (fn: callbackType, delay: number, ...args: (string | number)[]) => {
    setTimeout(() => {
        fn('args')
    }, delay)
}


delayExecFn(function (args) {
    console.log(args)
}, 3000, 'why', 18)

type tType = [string, number, delayExecFnType, delayExecFnType]

/**
 * 元组与数组的区别,数组存放相同数据类型 元组存放不同数据类型 通常用在函数返回值
 * @function testTuple
 * @description 一个函数 约束返回值为元组其中有三个子项 分别为 字符串 数字 自定义函数 类型
 */
function testTuple(a: string, b: string): [string, number, delayExecFnType] {

    let arr0: string[] = [a, b] //array

    let t: tType = ['gqq', 18, () => {
    }, () => {
    }] //tuple
    return [arr0[0], t[1], () => {
    }]
}

// 声明 不是赋值 对象专用   type是赋值 const
interface fuckYouInterFace {
    name: string,
    age: number
}

type fuckThemUnitType = string[]

interface fuckThem extends fuckYouInterFace {
    length: number,
    unit: fuckThemUnitType
}


const person: fuckThem = {
    name: 'GWW',
    age: 19,
    length: 18,
    unit: ['厘米', '米']
}

class P implements fuckThem {
    age: number;
    length: number;
    name: string;
    unit: fuckThemUnitType;
}

let p: P = new P()


p.age = 19
testTuple('1', '2')
export {name}

console.log(p);

